package springboot.study.project.schedule;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import springboot.study.project.util.nCoV_Crawler2019.EpidemicInfoService;

/**
 * @ClassName: NoticeSchedule
 * @Description: 通知定时器
 * @Author: baoxia
 * @Date: 2020-07-10 09:00
 * @Version: 1.0
 **/
@Component
public class NoticeSchedule {

    Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 每半小时更新一次
     */
    @Scheduled(fixedDelay = 1000 * 60 * 30)
    public void TimingPringt() {
        logger.info("更新疫情数据");
        EpidemicInfoService epidemicInfoService = new EpidemicInfoService();
        String news = epidemicInfoService.getNews();
        System.out.println(news);
    }

    /**
     * 每日凌晨更新一次
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void clearOldData() {
        // TODO：根据具体需要添加
        logger.info("凌晨一点进行执行...");
    }
}
